package cn.genmer.test.security;

import java.util.Arrays;
import java.util.Comparator;

public class SortArray {
    public static void main(String[] args) {
        int[][] ints = {{-2147483646, -2147483645}, {3, 4}, {2, 3}, {1, 2}, {2147483646, 2147483647}, {4, 5}};
        Arrays.sort(ints, new Comparator<int[]>() {
            public int compare(int[] interval1, int[] interval2) {
                if (interval1[1] < interval2[1]) {
                    return -1;
                } else if (interval1[1] > interval2[1]) {
                    return 1;
                } else {
                    return interval1[0] - interval2[0];
                }
            }
        });

        for (int[] interval : ints) {
            System.out.println(Arrays.toString(interval));
        }
    }
}